import { INJECT_MODEL_LIST_TAG, INJECT_PRESENT_LIST_TAG } from "../typed/injector-typed";

export type PresenterOptions = {
    propertyName?: any;
    propertyType?: any;
}

export const injectPresenter = function (propertyType1): (_constructor: any, propertyName: string) => any {
    return function (_constructor: any, propertyName: string): any {
        const propertyType: any = propertyType1;

        if (!Reflect.has(_constructor, INJECT_PRESENT_LIST_TAG)) {
            Reflect.set(_constructor, INJECT_PRESENT_LIST_TAG, []);
        }

        let injectInfoList = Reflect.get(_constructor, INJECT_PRESENT_LIST_TAG);
        injectInfoList.push({
            propertyName: propertyName,
            propertyType: propertyType
        });

        return (_constructor as any)[propertyName];
    }
}

export type ModelOptions = {
    propertyName?: any;
    propertyType?: any;
}

export const injectModel = function (propertyType1): (_constructor: any, propertyName: string) => any {
    return function (_constructor: any, propertyName: string): any {
        const propertyType: any = propertyType1;

        if (!Reflect.has(_constructor, INJECT_MODEL_LIST_TAG)) {
            Reflect.set(_constructor, INJECT_MODEL_LIST_TAG, []);
        }

        let injectInfoList = Reflect.get(_constructor, INJECT_MODEL_LIST_TAG);
        injectInfoList.push({
            propertyName: propertyName,
            propertyType: propertyType
        });

        return (_constructor as any)[propertyName];
    }
}
